import { http } from '@/utils/http'
import type {
  BannerItem,
  CategoryItem,
  newsItem,
  SignupItem,
  DetailItem,
  bannerItem,
  categoryItem,
  topGuests,
  userItem,
  BlogItem,
  giftItem,
  blogItem,
  signupItem,
  postTweetsItem,
  detailItem,
  GiftItem,
  thumbItem,
  likeItem,
  thumblist,
  sendGiftItem,
} from '@/types/index/home'

//封装轮播图api
export const getHomeBannerAPI = () => {
  return http<bannerItem>({
    url: '/get/api/v1/develop/banner',
    method: 'GET',
  })
}

//封装图标文字api
export const getCategoryIconListAPI = () => {
  return http<categoryItem>({
    url: '/get/api/v1/develop/homeclass',
    method: 'GET',
  })
}
// 封装获取活动API(报名进行中)
export const getSignupListAPI = () => {
  return http<signupItem>({
    url: '/get/api/v1/develop/activity',
    method: 'GET',
  })
}

export const getNewsListAPI = () => {
  return http<newsItem[]>({
    url: '',
    method: 'GET',
  })
}

// 封装添加访客API
export const postTopGuestsAPI = (data: topGuests) => {
  uni.request({
    url: '/get/api/v1/develop/visitor',
    method: 'POST',
    data: {
      user_id: uni.getStorageSync('userInfo').id,
      viewed_id: data.id
    },
    success: (res) => {
      console.log(res.data);
    }
  })
}

//封装获取活动详情API
export const getSignupDetailAPI = (activityId: string) => {
  return http<detailItem>({
    url: `/get/api/v1/develop/activity-details?a_id=${activityId}`,
    method: 'GET',
  })
}

// 保存发布内容
export const postTweetsAPI = (data: postTweetsItem) => {
  // console.log(data)
  return http({
    url: '/post/api/v1/develop/save',
    method: 'POST',
    data,
  })
}

// 获取博客列表
export const getBlogItemApi = (page: number) => {
  return http<BlogItem>({
    url: '/get/api/v1/develop/get-userblogs',
    method: 'GET',
    data: {
      page: page || 1
    }
  })
}

// 点赞博客
export const thumbBlogItemApi = (params: thumbItem) => {
  return http({
    url: '/post/api/v1/develop/like',
    method: 'GET',
    data: params,
  })
}

//获取博客点赞列表
export const getThumbBlogApi = (user_id: string) => {
  return http<thumblist>({
    url: '/get/api/v1/develop/like/get-like-list',
    method: 'GET',
    data: { user_id: user_id },
  })
}

// 获取博客喜欢列表
export const getLikeBlogApi = (user_id: string) => {
  return http({
    url: '/get/api/v1/develop/like/get-like-attention',
    method: 'GET',
    data: { user_id: user_id },
  })
}

//lth 喜欢博客
export const likeBlogItemApi = (pararm: { user_id_my: string; user_id_your: string }) => {
  return http({
    url: '/get/api/v1/develop/like/get-attention',
    method: 'GET',
    data: pararm,
  })
}

// 获取礼物列表
export const getGiftItemApi = () => {
  return http<GiftItem>({
    url: '/get/api/v1/develop/get-gift',
    method: 'GET',
  })
}

// 点击赠送礼物
export const postGiftItemApi = (params: sendGiftItem) => {
  return http({
    url: '/post/api/v1/develop/send-gift',
    method: 'POST',
    data: params,
  })
}

//获取金币

export const getCoinItemApi = (id: string) => {
  return http({
    url: '/get/api/v1/develop/getconins',
    method: 'GET',
    data: { id: id },
  })
}

// 封装报名API
export const postSignupAPI = (u_id: string, a_id: string) => {
  return http({
    url: '/get/api/v1/develop/activity-details',
    method: 'POST',
    data: {
      u_id: u_id,
      a_id: a_id,
    },
  })
}

//封装置顶嘉宾API
export const getTopGuestsAPI = () => {
  return http<topGuests>({
    url: '/get/api/v1/develop/topup',
    method: 'GET',
  })
}

//封装推荐嘉宾API
export const getUserItemAPI = () => {
  return http<userItem>({
    url: '/get/api/v1/develop/homedata',
    method: 'GET',
  })
}

//封装新增访客API
export const addVisitorAPI = (params: { user_id: string; viewed_id: string }) => {
  return http({
    url: '/get/api/v1/develop/visitor',
    method: 'POST',
    data: params,
  })
}

//封装搜索嘉宾API
export const getSearchUserAPI = () => {
  return http<userItem>({
    url: 'post/api/v1/develop/seek/recommend',
    method: 'POST',
  })
}
